<?php 
	session_start();
	include_once 'DB/DBConfig.php';
	include_once 'DB/HouseDAO.php';
    include_once 'DB/House.php';
	//require_once('html2pdf/html2pdf.class.php');
	
	if (isset($_POST['kind']) && $_POST['kind'] == 1){
	if (isset($_POST['roof']) && isset($_POST['gutter']) && isset($_POST['garage']) && isset($_POST['main_render']) && isset($_POST['paving']) && isset($_POST['windowframes']) && isset($_POST['gable']) && isset($_POST['front_door']) && isset($_POST['feature_render']) && isset($_POST['feature_wall']))
	{	
		try{

			$HouseDAO = new HouseDAO();
			$id = $_POST['id'];
			if($id !=1){
				$barge_scribe ="";
				$gable		  ="";
			}else{
				$barge_scribe = $_POST['barge_scribe'];
				$gable = $_POST['gable'];
			}
			$roof = $_POST['roof'];
			$gutter = $_POST['gutter'];
			$garage = $_POST['garage'];
			$main_render = $_POST['main_render'];
			$paving = $_POST['paving'];
			$windowframes = $_POST['windowframes'];
			$front_door = $_POST['front_door'];
			$feature_render = $_POST['feature_render'];
			$feature_wall = $_POST['feature_wall'];
			
			
			$House = new House();
			$House->setroof($roof);
			$House->setgetgutter($gutter);
			$House->setbarge_scribe($barge_scribe);
			$House->setgarage($garage);
			$House->setmain_render($main_render);
			$House->setpaving($paving);
			$House->setwindowframes($windowframes);
			$House->setgable($gable);
			$House->setfront_door($front_door);
			$House->setfeature_render($feature_render);
			$House->setfeature_wall($feature_wall);
			$House->setemail($_SESSION['email']);
			$House->setid($id);	
			$arr = $HouseDAO->getByemail($_SESSION['email']);

			if ($arr==null){
				$HouseDAO->insert($House);
			}else{$HouseDAO->update($House);
			}
			echo "1";
		} catch(Exception $e) {
			echo "2";
		}	
	}
}	
?>